import React from 'react'
import * as PropTypes from 'prop-types';
import ReactEcharts from 'echarts-for-react';
import echartsConfig from 'utils/echartsConfig'
import Tools from 'utils/tools'

class Pie extends React.Component {
    static defaultProps = {
        dataSource: [],
        columns: {},
    }
      
    render(){
        const { dataSource, columns, color, other, style = {height: '265px'} } = this.props;
        const Data = Tools.formatPieData(dataSource, columns);
        const Options = echartsConfig.PieECharts(Data, color, other)
        return (
            <ReactEcharts
                option={Options}
                notMerge={true}
                lazyUpdate={true}
                style={style}
            />
        )
    }
}

Pie.propTypes = {
    dataSource: PropTypes.array,
    columns: PropTypes.object,
}
export default Pie
